/* Now write out each data page, canonicalising page tables as we go... */
for ( ; ; )
{
- unsigned int prev_pc, sent_this_iter, N, batch;
+ unsigned int prev_pc, sent_this_iter, N, batch, run;
iter++;
sent_this_iter = 0;
}
/* entering this loop, pfn_type is now in pfns (Not mfns) */
+ run = 0;
for ( j = 0; j < batch; j++ )
{
unsigned long pfn, pagetype;
pfn = pfn_type[j] & ~XEN_DOMCTL_PFINFO_LTAB_MASK;
pagetype = pfn_type[j] & XEN_DOMCTL_PFINFO_LTAB_MASK;
- /* write out pages in batch */
+ if ( pagetype != 0 )
+ {
+ /* If the page is not a normal data page, write out any
+ run of pages we may have previously acumulated */
+ if ( run )
+ {
+ if ( ratewrite(io_fd, live,
+ (char*)region_base+(PAGE_SIZE*(j-run)),
+ PAGE_SIZE*run) != PAGE_SIZE*run )
+ {
+ ERROR("Error when writing to state file (4a)"
+ " (errno %d)", errno);
+ goto out;
+ }
+ run = 0;
+ }
+ }
+
+ /* skip pages that aren't present */
if ( pagetype == XEN_DOMCTL_PFINFO_XTAB )
continue;
if ( ratewrite(io_fd, live, page, PAGE_SIZE) != PAGE_SIZE )
{
- ERROR("Error when writing to state file (4)"
+ ERROR("Error when writing to state file (4b)"
" (errno %d)", errno);
goto out;
}
}
else
{
- /* We have a normal page: just write it directly. */
- if ( ratewrite(io_fd, live, spage, PAGE_SIZE) !=
- PAGE_SIZE )
- {
- ERROR("Error when writing to state file (5)"
- " (errno %d)", errno);
- goto out;
- }
+ /* We have a normal page: accumulate it for writing. */
+ run++;
}
} /* end of the write out for this batch */
+ if ( run )
+ {
+ /* write out the last accumulated run of pages */
+ if ( ratewrite(io_fd, live,
+ (char*)region_base+(PAGE_SIZE*(j-run)),
+ PAGE_SIZE*run) != PAGE_SIZE*run )
+ {
+ ERROR("Error when writing to state file (4c)"
+ " (errno %d)", errno);
+ goto out;
+ }
+ }
+
sent_this_iter += batch;
munmap(region_base, batch*PAGE_SIZE);